﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace Project01
{
  
    class MonsterType01:Monster
    {
        //Dữ liệu về Monster01
        private bool createbullets = false;
        
        public MonsterType01(Game game)
            : base(game)
        {
            this.ObjectTexture = game.Content.Load<Texture2D>("Images/Monster/Mtype01");
                this.Sprite = new AnimationSprite(ObjectTexture, 1, 4);
                this.Speed = 3;
                this.game = game;
                this.Health = 2;
                this.Type = 1;  
                
            
        }

        public override void LoadContent()
        {
            if (this.Sprite.Position.X >= game.Window.ClientBounds.Width / 2)
                MoveState = MonsterMove.Right;
            else
                MoveState = MonsterMove.Left;
            base.LoadContent();
        }

        public override void Update(GameTime gameTime)
        {

            Exp.Sprite.Position = SetPositionExplosion(Sprite.Position, 10, 0);
            this.Sprite.Update();
            if (MoveState == MonsterMove.Left)
            {
                if (this.Sprite.Position.Y >= game.Window.ClientBounds.Height / 3)
                {
                    this.Sprite.Position.X += Speed * 2;
                    if (!createbullets)
                    {
                        CreateBullets(this.Sprite.Position);
                        createbullets = true;
                    }
                    UpdateBullets(gameTime);

                }
            }
            else if (MoveState == MonsterMove.Right)
            {
                if (this.Sprite.Position.Y >= game.Window.ClientBounds.Height / 3)
                {
                    this.Sprite.Position.X -= Speed * 2;
                    
                    if (!createbullets)
                    {
                        CreateBullets(this.Sprite.Position);
                        createbullets = true;
                    }
                    UpdateBullets(gameTime);

                }
            }
            this.Sprite.Position.Y += Speed;
            Active = CheckPosition(Sprite.Position);


            base.Update(gameTime);
        }

        public override void Draw(SpriteBatch SpriteBatch)
        {
   

                for (int i = 0; i < Mbullets.Count; i++)
                {
                    Mbullets[i].Draw(SpriteBatch);
                }
            base.Draw(SpriteBatch);
        }
    }
}
